﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Net4.Common.Entities
{
    public class Message
    {
        #region Fields

        private int _Id;

        public int Id
        {
            get { return _Id; }
            set { _Id = value; }
        }

        private string _UserName;

        public string UserName
        {
            get { return _UserName; }
            set { _UserName = value; }
        }

        private string _Email;

        public string Email
        {
            get { return _Email; }
            set { _Email = value; }
        }

        private string _Subject;

        public string Subject
        {
            get { return _Subject; }
            set { _Subject = value; }
        }

        private string _Body;

        public string Body
        {
            get { return _Body; }
            set { _Body = value; }
        }

        private string _Reply = string.Empty;

        public string Reply
        {
            get { return _Reply; }
            set 
            {
                _Reply = value; 
            }
        }

        private DateTime _CreateDate;

        public DateTime CreateDate
        {
            get { return _CreateDate; }
            set { _CreateDate = value; }
        }

        private DateTime _ReplyDate;

        public DateTime ReplyDate
        {
            get { return _ReplyDate; }
            set { _ReplyDate = value; }
        }

        private string _UserIP;

        public string UserIP
        {
            get { return _UserIP; }
            set { _UserIP = value; }
        }

        public bool HasReply
        {
            get
            {
                return !string.IsNullOrEmpty(_Reply);
            }
        }

        #endregion

        public Message(string userName, string email, string subject, string body, string userIP)
        {
            Check.ArgumentIsNotNull(userName, "userName");
            Check.ArgumentIsNotNull(email, "email");
            Check.ArgumentIsNotNull(subject, "subject");
            Check.ArgumentIsNotNull(body, "body");

            _UserName = userName;
            _Email = email;
            _Subject = subject;
            _Body = body;
            _CreateDate = DateTime.Now;
            _UserIP = userIP;
        }

        public Message(int id, string userName, string email, string subject, string body, string userIP,
            DateTime createDate, string reply, DateTime replyDate)
        {
            Check.ArgumentIsNotNull(userName, "userName");
            Check.ArgumentIsNotNull(email, "email");
            Check.ArgumentIsNotNull(subject, "subject");
            Check.ArgumentIsNotNull(body, "body");

            _Id = id;
            _UserName = userName;
            _Email = email;
            _Subject = subject;
            _Body = body;
            _UserIP = userIP;
            _CreateDate = createDate;
            _Reply = reply;
            _ReplyDate = replyDate;
        }
    }
}
